package com.zjh.photoshopstudy.app.upload;

import com.google.gson.Gson;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.convert.StringConvert;
import com.lzy.okgo.request.PostRequest;
import com.lzy.okserver.OkUpload;
import com.lzy.okserver.upload.UploadTask;
import com.zjh.photoshopstudy.Model.VideoEntity;

import java.io.File;

public class UploadHttp {
    public static String webRoot_URL = "http://192.168.0.102:8080/video/";
    String url = "imageUpload";

    public void upload(VideoEntity video, File[] files) {
        Gson gson = new Gson();
        PostRequest<String> postRequest = OkGo.<String>post(webRoot_URL + url).converter(new StringConvert())
                .params("video", gson.toJson(video));
        for (File file : files) {
            postRequest.params("files", file);
        }
        postRequest.converter(new StringConvert());
        OkUpload.request(video.getvTitle(), postRequest)
                .extra1(video)//
                .save()
        .start();
    }
}
